<!-- 团奖申请详情 -->
<template>
	<div class="groupAwardApplyDetail">
		<el-breadcrumb separator="/" class="bread-title">
			<el-breadcrumb-item :to="{ path: '/groupAwardApply' }">团奖申请</el-breadcrumb-item>
			<el-breadcrumb-item v-if="pageType==='edit'">编辑</el-breadcrumb-item>
			<el-breadcrumb-item v-if="pageType==='add'">申请</el-breadcrumb-item>
		</el-breadcrumb>
		<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="140px" class="demo-ruleForm">
			<el-form-item label="选择结佣项目：" prop="devId">
				<el-select  :disabled="pageType==='edit'" v-model="ruleForm.devId" filterable  @change="selectEstates">
					<el-option v-for="(item,index) in estateslist"
					           :key="index"
					           :label="item.devName"
					           :value="item.devId">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="关键人信息：" prop="keyPerson">
				<span>{{ruleForm.keyPerson}}</span>
			</el-form-item>
			<el-form-item label="选择结佣方式：" prop="settleCommMode" >
				<el-radio-group v-model="ruleForm.settleCommMode"  @change="selectsettleCommMode">
				  <el-radio :label="0">购物卡</el-radio>
				  <el-radio :label="1">第三方</el-radio>
				  <el-radio :label="2">劳务所得</el-radio>
				</el-radio-group>
			</el-form-item>
			<!-- 购物卡 -->
			<div v-if="ruleForm.settleCommMode==0 || ruleForm.settleCommMode==2">
				<el-form-item label="姓名：" prop="customerName">
					<el-input v-model="ruleForm.customerName" placeholder="请输入姓名" maxlength="30" style="width: 300px"></el-input>
				</el-form-item>
				<el-form-item label="手机号：" prop="customerPhone">
					<el-input v-model="ruleForm.customerPhone" placeholder="请输入手机号" style="width: 300px" ></el-input>
				</el-form-item>
				<el-form-item label="身份证：" prop="customerId">
					<el-input v-model="ruleForm.customerId" style="width: 300px" placeholder="请输入身份证"></el-input>
				</el-form-item>
			</div>
			<!-- 第三方 -->
			<div style="display: flex;" v-if="ruleForm.settleCommMode==1">
				<p>
					<el-form-item label="开户行：" prop="bankName" >
						<el-input v-model="ruleForm.bankName" :disabled="true" style="width: 300px" placeholder="选择第三方公司账号信息"></el-input>
					</el-form-item>
					<el-form-item label="开户行名称：" prop="openingBank" >
						<el-input v-model="ruleForm.openingBank" :disabled="true" style="width: 300px" placeholder="选择第三方公司账号信息"></el-input>
					</el-form-item>
					<el-form-item label="开户账号：" prop="bankAccount1">
						<el-input v-model="ruleForm.bankAccount1"  :disabled="true" style="width: 300px" placeholder="选择第三方公司账号信息"></el-input>
					</el-form-item>
					<el-form-item label="公司名称：" prop="companyName" >
						<el-input v-model="ruleForm.companyName" :disabled="true" style="width: 300px" placeholder="选择第三方公司账号信息"></el-input>
					</el-form-item>
				</p>
				<p style="margin-left: 20px">
					<el-button @click="selectDialogVisible2=true">选择第三方公司账号信息</el-button>
				</p>
			</div>
			<!-- 劳务所得 -->
			<div v-if="ruleForm.settleCommMode==2">
				<el-form-item label="开户行所在省:" prop="openBankProvince" >
					<el-select v-model="ruleForm.openBankProvince" filterable  style="width: 300px" @change="selectProvince">
						<el-option v-for="(item,index) in provincelist"
									:key="index"
									:label="item.province"
									:value="item.provinceid">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="开户行所在市:" prop="openBankCity" >
					<el-select v-model="ruleForm.openBankCity" filterable  style="width: 300px" >
						<el-option v-for="(item,index) in provicecitylist"
									:key="index"
									:label="item.city"
									:value="item.cityId">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="开户行：" prop="openingBank1" >
					<el-select v-model="ruleForm.openingBank1" filterable  style="width: 300px" @change="selectbank">
						<el-option v-for="(item,index) in banklist"
									:key="index"
									:label="item.bankName"
									:value="item.bankCode">
						</el-option>
					</el-select><span style="color:red">目前仅支持以下银行！</span>
				</el-form-item>
				<el-form-item label="开户行支行：" prop="bankBranch" >
					<el-select v-model="ruleForm.bankBranch" filterable  style="width: 300px"  >
						<el-option v-for="(item,index) in bankbranchlist"
									:key="index"
									:label="item.bankBranchName"
									:value="item.linkNumber">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="开户账号：" prop="bankAccount" >
					<el-input v-model="ruleForm.bankAccount"  type="number"   maxlength="30" style="width: 300px" placeholder="请输入银行卡号"></el-input>
				</el-form-item>
			</div>
			<hr>
			<el-form-item label="应结团奖：" prop="card">
				<span>{{priceTotal}}</span>
			</el-form-item>
			<div style="margin-left: 30px">
				<el-button @click="selectSettleOrder()">选择结佣订单</el-button>
				<el-table :data="tableData2" border style="width: 80%;margin-top: 20px" ref="table" @select="select2" @select-all="selectAll2"  :row-class-name="tableRowClassName">
					<el-table-column type="selection" width="55" align="center"></el-table-column>
					<el-table-column label="城市" prop="cityName" align="center"></el-table-column>
					<el-table-column label="客户姓名" prop="customerName" align="center"></el-table-column>
					<el-table-column label="手机号" prop="customerPhone" align="center"></el-table-column>
					<el-table-column label="楼盘名称" prop="devName" align="center"></el-table-column>
					<el-table-column label="客户状态" prop="nodeName" align="center"></el-table-column>
					<el-table-column label="应结团奖" prop="shouldTeamReward" align="center"></el-table-column>
					<el-table-column label="交易时间" prop="tradeTime" align="center"></el-table-column>
					<el-table-column label="是否符合标准" prop="conformStandard" align="center">
						<template  slot-scope="scope">
							<span v-if="scope.row.conformStandard==0">无</span>
							<span v-if="scope.row.conformStandard==1">是</span>
							<span v-if="scope.row.conformStandard==2">否</span>
						</template>
					</el-table-column>
				</el-table>

				<div class="pagebar">
					<el-pagination
					        background
					        layout="total, sizes, prev, pager, next"
					        :current-page.sync="pagination2.pageNum"
					        :page-sizes="[10, 20, 30, 40]"
					        :page-size="pagination2.pageSize"
					        @size-change="sizeChange"
					        @current-change="currentChange"
					        :total="pagination2.totalRows">
					</el-pagination>
				</div>

				<el-dialog
				        title=""
				        :visible.sync="selectDialogVisible2"
				        width="40%"
				        class="dialog"
				        center>
						<div>
							<el-row :span="24" :gutter="20">
							    <el-col :span="18">
							        <el-input
							                placeholder="请输入内容"
							                prefix-icon="el-icon-search"
							                size="normal"
							                v-model="searchname">
							        </el-input>
							    </el-col>
							    <el-col :span="6">
							        <el-button size="normal" type="primary" @click="searchlist">查询</el-button>
							    </el-col>
							</el-row>

							<div class="mt20" style="margin-left: 60px;height: 400px;overflow-y: auto;">
							    <div class="selectedInterval-item" v-for="item in accountInfoList" @click="selectradio(item.id)">
							         <div>
							            <el-radio @change="selectradio(item.id)" :label="item.id" v-model="accountSelect" key="item.id" :value="item.id">&nbsp;</el-radio>
							         </div>
							         <div>
							            <div>公司名称:{{item.companyName}}</div>
							            <div>开户名称：{{item.bankName}}</div>
							            <div>开户行名称：{{item.openingBank}}</div>
							            <div>开户账号：{{item.bankAccount}}</div>
							            <div>开户行所属城市：{{item.openingBankCity}}</div>
							            <div>联系电话：{{item.companyPhone}}</div>
							         </div>
							    </div>
							</div>
						</div>
						<span slot="footer" class="dialog-footer"  style="text-align: center !important;">
						    <el-button @click="selectDialogVisible2 = false">取 消</el-button>
						    <el-button  type="primary" @click="ensure(1)">确定</el-button>
						</span>
				</el-dialog>

				<!-- 选择结佣订单 -->
				<el-dialog
				        title=""
				        :visible.sync="selectDialogVisible"
				        width="60%"
				        class="dialog"
				        center>
						<div>
							<el-table :data="tableData" border style="width: 100%;margin-top: 20px" ref="multipleTable"  @select="select" @select-all="selectAll"  :row-class-name="tableRowClassName">
								<el-table-column type="selection" width="55" align="center"></el-table-column>
								<el-table-column label="城市" prop="cityName" align="center"></el-table-column>
								<el-table-column label="客户姓名" prop="customerName" align="center"></el-table-column>
								<el-table-column label="手机号" prop="customerPhone" align="center"></el-table-column>
								<el-table-column label="楼盘名称" prop="devName" align="center"></el-table-column>
								<el-table-column label="客户状态" prop="nodeName" align="center"></el-table-column>
								<el-table-column label="应结团奖" prop="shouldTeamReward" align="center"></el-table-column>
								<el-table-column label="交易时间" prop="tradeTime" align="center"></el-table-column>
								<el-table-column label="是否符合标准" prop="conformStandard" align="center">
									<template  slot-scope="scope">
										<span v-if="scope.row.conformStandard==0">无</span>
										<span v-if="scope.row.conformStandard==1">是</span>
										<span v-if="scope.row.conformStandard==2">否</span>
									</template>
								</el-table-column>
							</el-table>

							<div class="pagebar">
						        <el-pagination
						                background
						                layout="total, sizes, prev, pager, next"
						                :current-page.sync="pagination.pageNum"
						                :page-sizes="[10, 20, 30, 40]"
						                :page-size="pagination.pageSize"
						                @size-change="handleSizeChange"
						                @current-change="handleCurrentChange"
						                :total="pagination.totalRows">
						        </el-pagination>
							</div>

						</div>
				        <span slot="footer" class="dialog-footer"  style="text-align: center !important;">
				        	<el-button @click="selectDialogVisible = false">取 消</el-button>
				            <el-button  type="primary" @click="ensure(2)">确定</el-button>
				        </span>
				</el-dialog>

				<div>
					<p class="star">
						好生活内部决策审批：
						<Upload :multiple="true" ref="upload1" :fileList="decisionApproval"/>
					</p>
					<p class="star">
						好生活结佣确认表：
						<Upload :multiple="true" ref="upload2" :fileList="settleCommConfirm"/>
					</p>
				</div>
				 <div v-show="ruleForm.settleCommMode==1">
					<p class="star">
						好生活付款明细：
						<Upload :multiple="true" ref="upload3" :fileList="paymentDetails"/>
					</p>
				</div>
				 <div v-show="ruleForm.settleCommMode==2">
					<p class="star">
						身份证复印件：
						<Upload :multiple="true" ref="upload4" :fileList="idCardCopyFile"/>
					</p>
					<p class="star">
						银行卡复印件：
						<Upload :multiple="true" ref="upload5"  :fileList="bankCardCopyFile"/>
					</p>
				</div>
				<p style="text-align: center">
					<el-button type="primary" @click="$router.push({path: '/groupAwardApply'})">取消</el-button>
					<el-button type="primary" @click="savehander('ruleForm')">{{pageType=='add'?'保存':'提交审核'}}</el-button>
				</p>
			</div>
		</el-form>
	</div>
</template>
<script>

	import Upload from '@/components/common/Upload'
	import api from '@/api/apiPath'
	export default {
		components: {Upload},
		data() {
			return {
				batchId:'',
				pageType:'add',
				projectlist:[],
				estateslist:[],
				decisionApproval:[],//好生活内部决策审批
				settleCommConfirm:[],//好生活结佣确认表
				paymentDetails:[],//付款明细（只有第三方时需要传）
				idCardCopyFile:[],//身份证复印件（只有个人劳务所得需要传
				bankCardCopyFile:[],//银行卡复印件（只有个人劳务所得需要传）
				searchname:'',//第三方查询

				banklist:[],//劳务所得开户行
				provincelist:[],//开户行所在省
				provicecitylist:[],//省下市
				bankbranchlist:[],//开户行支行

				companyinfo:{},//第三方公司信息

				ruleForm:{
					devId:'',
					devName:'',
					keyPerson:'',//关键人信息

					customerName:undefined,
					customerPhone:undefined,
					customerId:undefined,

					bankName:undefined,//开户行
					openingBank:undefined,//开户行名称
					bankAccount:undefined,//开户账号
					companyName:undefined,//公司名称
					companyId:undefined,//公司id

					shouldTeamReward:undefined,//应结团奖
					bankAccount:undefined, //开户账号
					bankAccount1:undefined, //开户账号
					bankBranch:undefined,//劳务所得 支行

					openBankProvince:'110000',//劳务所得 省
					openBankCity:'',//开户城市
					openingBank1:undefined,//开户行

					upimg:'',
				},
				rules:{
					devId:[
						{required:true,message:'请选择结佣项目',trigger:'blur'}
					],
					settleCommMode:[
						{required:true,message:'请选择结佣方式',trigger:'blur'}
					],
					customerName:[
						{required:true,message:'请输姓名',trigger:'blur'}
					],
					customerPhone:[
						{required:true,message:'请输入手机号',trigger:'blur'}
					],
					customerId:[
					    {required:true,message:'请输入身份证号',trigger:'blur'}
					],
					//第三方
					bankName:[
						{required:true,message:'选择第三方账户信息',trigger:'blur'}
					],
					openingBank:[
						{required:true,message:'开户行名称不能为空',trigger:'blur'}
					],
					company:[
						{required:true,message:'选择第三方账户信息',trigger:'blur'}
					],
					bankAccount1:[
						{required:true,message:'选择第三方账户信息',trigger:'blur'}
					],
					bankAccount:[
						{required:true,message:'输入开户行帐号',trigger:'blur'}
					],
					bankBranch:[
						{required:true,message:'开户行支行不能为空',trigger:'blur'}
					],
					openBankProvince:[
						{required:true,message:'请选择开户行所在省',trigger:'blur'}
					],
					openBankCity:[
						{required:true,message:'请选择开户行所在市',trigger:'blur'}
					]
				},
				name:'',
				selectDialogVisible:false,
				selectDialogVisible2:false,
				tableData2:[],
				multipleSelection1: [], //选中的数据
				accountInfoList:[],//账号信息
				accountSelect:'',
				//弹框中
				tableData:[],
				selectMap: {},
				pagination: {
				  pageNum:1,
				  totalRows: 0, //总条数
				  pageSize: 10, //每页显示条数
				},
				//页面
				pagination2: {
				  pageNum:1,
				  totalRows: 0, //总条数
				  pageSize: 10, //每页显示条数
				},
			}
		},
		created(){
			this.pageType = this.$route.query.pageType
			this.batchId = this.$route.query.id
			this.allestate()
			if (this.pageType == 'edit') {
				this.getinfo()
			}
		},
		methods:{
			getinfo(){
				this.axios.post(api.VIEWTEAMREWARDAPPLY,{batchId:this.$route.query.id}).then(res=>{
					if (res.data.code == 200) {
						let groupinfo = res.data.data.teamRewardApply
						this.ruleForm.devId = (groupinfo.devId).toString()
						this.ruleForm.devName = groupinfo.devName
					    this.ruleForm.keyPerson = groupinfo.keyPerson
						this.tableData2 = res.data.data.teamRewardOrderList
						this.ruleForm.customerName = groupinfo.name
						this.ruleForm.customerPhone = groupinfo.mobile
						this.ruleForm.customerId = groupinfo.idCard
						this.$set(this.ruleForm,'settleCommMode',groupinfo.settleCommMode)
						this.getapplylist()//根据楼盘查询获取结佣订单数据
						//选择框的选中状态
						// this.toggleSelection()
						//选中的数据
						this.tableData2.forEach((item) => {
						    this.selectMap[item.orderUniqueId] = item
						})
						this.calcMultipleSelection()
						this.toggleSelection2(this.tableData2)
						this.pagination2.totalRows = this.tableData2.length
						if (this.ruleForm.settleCommMode == 1 ) {
							this.getbrokercompany()
							this.ruleForm.bankName = groupinfo.bankName
							this.ruleForm.openingBank = groupinfo.openBank
							this.ruleForm.companyName = groupinfo.companyName
							this.ruleForm.companyId = groupinfo.companyId
							this.ruleForm.bankAccount1 = groupinfo.bankAccount
						}
						//获取劳务所得 选中框中的数据
						if (this.ruleForm.settleCommMode == 2) {
							this.ruleForm.openBankProvince = groupinfo.openBankProvinceCode//省
							this.ruleForm.openBankCity = groupinfo.openBankCityCode//市
							this.ruleForm.openingBank1 = groupinfo.openBankCode //要调整 开户行
							this.ruleForm.bankBranch = groupinfo.bankNumber//开户行支行
							this.ruleForm.bankAccount = groupinfo.bankAccount
							this.getprovincelist()//省list
							this.getcitylist()//市
							this.getallbank()
							this.getbankbranch()//支行
						}
						this.decisionApproval = JSON.parse(groupinfo.decisionApproval)
						this.settleCommConfirm =  JSON.parse(groupinfo.settleCommConfirm)
						if (groupinfo.paymentDetails) {
							this.paymentDetails = JSON.parse(groupinfo.paymentDetails)
						}
						if (groupinfo.idCardCopyFile) {
							this.idCardCopyFile = JSON.parse(groupinfo.idCardCopyFile)
						}
						if (groupinfo.bankCardCopyFile) {
							this.bankCardCopyFile = JSON.parse(groupinfo.bankCardCopyFile)
						}
					}
				})
			},
			selectbank(){
				this.ruleForm.bankBranch =''
				this.getbankbranch()
			},
			getbankbranch(){
				this.axios.post(api.KINGDEEBANKBRANCHLIST,{bankId:this.ruleForm.openingBank1,provinceId:this.ruleForm.openBankProvince}).then(res=>{
					if (res.data.code == 200) {
						this.bankbranchlist = res.data.data
					}
				})
			},
			//根据省id  查找市
			selectProvince(){
				this.ruleForm.openBankCity = ''
				this.ruleForm.bankBranch =''
				this.getcitylist()
			},
			getcitylist(){
				this.axios.get(api.CITYLISTPROVINECEID+'/'+this.ruleForm.openBankProvince).then(res=>{
					if (res.data.code == 200) {
						this.provicecitylist = res.data.data.cityList
					}
				})
			},
			getprovincelist(){
				this.axios.get(api.CITYPROVINCES).then(res=>{
					if (res.data.code == 200) {
						this.provincelist = res.data.data
					}
				})
			},
			tableRowClassName({row, rowIndex}) {
				if(row.conformStandard !== 1){
					return 'warning-row';
				}
				return '';
			},
			getallbank(){
				this.axios.post(api.TEAMREWARDBANKALL).then(res=>{
					if (res.data.code ==200) {
						this.banklist = res.data.data
					}
				})
			},
			getbrokercompany(){
				this.axios.post(api.GETBROKERCOMPANYLIST,{companyNamePhone:this.searchname}).then(res=>{
					if (res.data.code==200) {
						this.accountInfoList = res.data.data
					}
				})
			},
			//选择结佣方式
			selectsettleCommMode(){
			    //第三方
				if (this.ruleForm.settleCommMode==1) {
					this.getbrokercompany()//获取第三方公司列表查询
				}else if(this.ruleForm.settleCommMode==2){
					this.getallbank()//劳务所得 开户行
					this.getprovincelist()//劳务所得 获得省list
					this.selectProvince()//省 市
				}
			},
			selectEstates(){
				//获取楼盘名称
			    let tempobj=this.estateslist.find(item=>{
					return item.devId == this.ruleForm.devId
				})
				this.ruleForm.devName = tempobj.devName
				this.getapplylist()//根据楼盘查询获取结佣订单数据
				this.getkeyperson()//根据楼盘查询关键人
			},
			getkeyperson(){
				this.axios.post(api.GETKEYPERSONBYDEVID,{devId:this.ruleForm.devId,}).then(res=>{
					if (res.data.code == 200) {
						this.ruleForm.keyPerson = res.data.data.keyPerson
						if (this.ruleForm.keyPerson) {
							let temparr = this.ruleForm.keyPerson .split('-')
							this.ruleForm.customerName = temparr[0]
							this.ruleForm.customerPhone = temparr[1]
						}
					}
				})
			},
			allestate(){
				this.axios.post(api.ALLESTATEDEVS,{}).then(res=>{
					if (res.data.code == 200) {
						this.estateslist = res.data.data
					}
				})
			},
		  	getuploadhander(){
				if (this.ruleForm.settleCommMode == 0 || this.ruleForm.settleCommMode == 2) {
					let reg=/^1(3|4|5|6|7|8)\d{9}$/g;
					if(this.ruleForm.customerPhone.length<11){
						this.$message({
						    message: '请输入正确的手机号',
						    type: 'warning'
						});
						return
					}
					if(!(reg.test(this.ruleForm.customerPhone))){
						this.$message({
						    message: '手机号有误，请重新输入',
						    type: 'warning'
						});
						return
					}
					//身份证校验
					var regIdNo = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
					if (!(regIdNo.test(this.ruleForm.customerId))) {
						this.$message({
						    message: '身份证号有误，请重新输入',
						    type: 'warning'
						});
						return
					}
				}
				if (this.multipleSelection1.length <1) {
					this.$message({
					    message: '请选中结佣订单',
					    type: 'warning'
					});
					return
				}
		  		Promise.all([
		  			this.$refs.upload1.submit(),
		  			this.$refs.upload2.submit(),
		  			this.$refs.upload3.submit(),
		  			this.$refs.upload4.submit(),
		  			this.$refs.upload5.submit(),
		  		]).then(res=>{
					if (res[0].length < 1) {
						this.$message({
						    message: '好生活内部决策审批不能为空',
						    type: 'warning'
						});
						return
					}
					if (res[1].length < 1) {
						this.$message({
						    message: '好生活结佣确认表不能为空',
						    type: 'warning'
						});
						return
					}
					if (this.ruleForm.settleCommMode === 1) {
						if (res[2].length < 1) {
							this.$message({
							    message: '好生活付款明细不能为空',
							    type: 'warning'
							});
							return
						}
					}else if(this.ruleForm.settleCommMode === 2){
						if (res[3].length < 1) {
							this.$message({
							    message: '身份证复印件不能为空',
							    type: 'warning'
							});
							return
						}
						if (res[4].length < 1) {
							this.$message({
							    message: '银行卡复印件不能为空',
							    type: 'warning'
							});
							return
						}
					}
					let obj = {}
					obj['keyPerson'] = this.ruleForm.keyPerson
					obj['devId'] = this.ruleForm.devId
					obj['devName'] = this.ruleForm.devName
					obj['settleCommMode'] = this.ruleForm.settleCommMode
					if (this.ruleForm.settleCommMode !== 1) {
						obj['name'] = this.ruleForm.customerName
						obj['mobile'] = this.ruleForm.customerPhone
						obj['idCard'] = this.ruleForm.customerId
					}
					obj['decisionApproval'] = JSON.stringify(res[0])
					obj['settleCommConfirm'] = JSON.stringify(res[1])
					if(this.ruleForm.settleCommMode == 1){
						obj['paymentDetails'] = JSON.stringify(res[2])
						obj['companyName'] = this.ruleForm.companyName
						obj['bankName'] = this.ruleForm.bankName
						obj['openBank'] = this.ruleForm.openingBank
						obj['bankAccount'] = this.ruleForm.bankAccount1
						obj['companyId'] = this.ruleForm.companyId
						obj['openBankProvince'] = this.companyinfo.openingBankProvince
						obj['openBankCity'] = this.companyinfo.openingBankCity
						obj['bankNumber'] = this.companyinfo.bankNumber

					}else if(this.ruleForm.settleCommMode == 2){
						let cobj = this.provicecitylist.find(item=>{
						 	return item.cityId == this.ruleForm.openBankCity
						})
						let bobj = this.bankbranchlist.find(item=>{
							return item.linkNumber ==  this.ruleForm.bankBranch
						})
						let objbank = this.banklist.find(item=>{
							return item.bankCode == this.ruleForm.openingBank1
						})

						let probj = this.provincelist.find(val=>{
							return val.provinceid == this.ruleForm.openBankProvince
						})
						obj['idCardCopyFile'] = JSON.stringify(res[3])
						obj['bankCardCopyFile'] = JSON.stringify(res[4])
						obj['openBank'] = objbank.bankName//开户行名称
						obj['openBankCode'] = this.ruleForm.openingBank1//开户行编码
						obj['openBankProvinceCode']= this.ruleForm.openBankProvince//省编码
						obj['openBankProvince'] = probj.province//省name
						obj['openBankCityCode'] = this.ruleForm.openBankCity
						obj['openBankCity'] = cobj['city'] //开户行城市
						obj['bankNumber'] = bobj.linkNumber
						obj['bankAccount'] = this.ruleForm.bankAccount
						obj['bankBranch'] = bobj.bankBranchName
					}
					// obj['shouldTeamReward'] = this.ruleForm.shouldTeamReward
					obj['orderList'] = this.multipleSelection1

				  	if (this.pageType == 'edit') {
				  		obj['batchId'] =this.batchId
				  	}
				    this.axios.post(api.SAVEAPPLYTEAMREWARD,obj).then(res=>{
						if(res.data.code == 200){
							this.$message({
							    message: this.pageType=='add' ? '新增成功':'编辑成功',
							    type: 'success'
							});
							this.$router.go(-1)
						}
				    })
		  		})
		 	},
			savehander(formName){
				this.$refs[formName].validate((valid) => {
				  if (valid) {
					this.getuploadhander()//获取上传图片
				  }else {
				  	return false
				  }
				});
			},
			select(arr, val) {
			    if (this.selectMap[val.orderUniqueId]) {
			        delete this.selectMap[val.orderUniqueId]
			    } else {
			        this.selectMap[val.orderUniqueId] = val;
			    }
			    this.calcMultipleSelection()
			},
			selectAll(arr) {
			    if (arr.length) {
			        arr.forEach((item) => {
			            this.selectMap[item.orderUniqueId] = item;
			        })
			    } else {
			        this.tableData.forEach((item) => {
			            delete this.selectMap[item.orderUniqueId]
			        })
			    }
			    this.calcMultipleSelection()
			},
			calcMultipleSelection(){
				let multipleSelection = [];
				for (let key in this.selectMap) {
				    multipleSelection.push(this.selectMap[key]);
				}
				this.multipleSelection1 = multipleSelection;
			},
			handleCurrentChange() {
			    this.getapplylist()
			},
			handleSizeChange(val) {
			    this.pagination.pageSize = val
			    this.getapplylist();
			},
			getapplylist() {
			    this.axios.post(api.GETAPPLYCALCULATE, {
			    	devId:this.ruleForm.devId,
			        pageSize: this.pagination.pageSize,
			        pageNum: this.pagination.pageNum,
			    }).then((res) => {
			        this.tableData = res.data.data.list;
			        this.pagination.totalRows = res.data.data.total;

			        let rows = [];
			        this.tableData.forEach((item, index) => {
			            if (this.selectMap[item.orderUniqueId]) {
			                rows.push(item)
			            }
			        });
			        this.toggleSelection(rows)
			    })
			},
			toggleSelection(rows) {
				setTimeout(() => {
				    rows.forEach((row) => {
				        this.$refs.multipleTable.toggleRowSelection(row)
				    })
				}, 30)
			},
			searchlist(){
				this.getbrokercompany()
			},
			ensure(type){
				if (type==1) {
					//第三方公司信息
					this.companyinfo = this.accountInfoList.find(item=>{
						return item.id == this.accountSelect
					})
					this.ruleForm.bankName = this.companyinfo.bankName
					this.ruleForm.openingBank = this.companyinfo.openingBank
					this.ruleForm.bankAccount1 = this.companyinfo.bankAccount
					this.ruleForm.companyName = this.companyinfo.companyName
					this.ruleForm.companyId = this.companyinfo.id
					this.selectDialogVisible2 = false
				}else if(type == 2){
					this.tableData2 = this.multipleSelection1
					this.selectDialogVisible = false
					this.currentChange(1)
				}
			},
			select2(arr, val) {
			    if (this.selectMap[val.orderUniqueId]) {
			        delete this.selectMap[val.orderUniqueId]
			    } else {
			        this.selectMap[val.orderUniqueId] = val;
			    }
			    this.changSelection()
			    this.calcMultipleSelection()
			},
			selectAll2(arr) {
			    if (arr.length) {
			        arr.forEach((item) => {
			            this.selectMap[item.orderUniqueId] = item;
			        })
			    } else {
			        this.tableData2.forEach((item) => {
			            delete this.selectMap[item.orderUniqueId]
			        })
			    }
			    this.changSelection()
			    this.calcMultipleSelection()
			},
			// 改变弹框选中数据
			changSelection(){
				let rows = [];
				this.tableData.forEach((item, index) => {
				    if (this.selectMap[item.orderUniqueId]) {
				        rows.push(item)
				    }
				});
				if (this.$refs.multipleTable !== undefined) {
					this.$refs.multipleTable.clearSelection();
				}
				this.toggleSelection(rows)
			},
			// 改变弹框选中数据
			changSelection2(){
				let rows = [];
				this.tableData2.forEach((item, index) => {
				    if (this.selectMap[item.orderUniqueId]) {
				        rows.push(item)
				    }
				});
				this.$refs.table.clearSelection();
				this.toggleSelection2(rows)
			},
			//选择确认后 选中效果
			toggleSelection2(rows) {
				setTimeout(() => {
				    rows.forEach((row) => {
				        this.$refs.table.toggleRowSelection(row)
				    })
				}, 30)
			},
			selectradio(val){
			    this.accountSelect = +val
			},
			selectSettleOrder(){
				this.selectDialogVisible = true
			},
			currentChange(page){
				this.pagination2.totalRows = this.multipleSelection1.length;
				this.pagination2.pageNum = page
				this.tableData2 = this.multipleSelection1.slice((this.pagination2.pageNum - 1) * this.pagination2.pageSize, this.pagination2.pageNum * this.pagination2.pageSize);
			    this.changSelection2()

			},
			//改变每页显示条数的时候调用一次
			sizeChange(size){
				this.pagination2.pageSize = size
				this.pagination2.pageNum = 1
				this.tableData2 = this.multipleSelection1.slice((this.pagination2.pageNum - 1) * this.pagination2.pageSize, this.pagination2.pageNum * this.pagination2.pageSize);
				this.changSelection2()//改变分页 选中框选中状态
				this.pagination2.totalRows = this.multipleSelection1.length;
			}
		},
		computed:{
			//应结团奖
			priceTotal(){
				let totalReward = 0;
				for (let key in this.multipleSelection1) {
				    totalReward += +this.multipleSelection1[key].shouldTeamReward
				}
				this.ruleForm.shouldTeamReward = totalReward
				return totalReward.toFixed(2);
			}
		}
	}
</script>
<style lang="stylus">
	.groupAwardApplyDetail .el-table .warning-row {
		color:red;
	}
	.groupAwardApplyDetail .star:before{
		content: '*';
		color: red;
		margin-right:2px;
		display: inline-block;
		height: 100%;
		vertical-align: middle
	}

	.selectedInterval-item {
	    display: flex;
	    justify-content: center;
	    align-items: center;
	    margin-top: 20px;

	    > div:first-child {
	        width: 50px;
	        text-align: center;
	    }
	    > div:last-child {
	        flex: 1;
	    }
	}

</style>
